{% extends "comments/base.html" %}
{% load i18n %}
{% load markup %}
{% load miraflores_tags %}

{% block title %}{% trans "Preview your comment" %}{% endblock %}

{% block content %}
{% load comments %}
  <form action="{% comment_form_target %}" method="post">
    {% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}
    {% if form.errors %}
    <h1>{% blocktrans count form.errors|length as counter %}Please correct the error below{% plural %}Please correct the errors below{% endblocktrans %}</h1>
    {% else %}
    <h1>{% trans "Preview your comment" %}</h1>
      <div class="comment">{{ comment|markdown|sanitize:"p a:href br ul ol li strong em b i"|safe }}</div>
      <p>
      {% trans "and" %} <input type="submit" name="submit" class="submit-post" value="{% trans "Post your comment" %}" id="submit" /> {% trans "or make changes" %}:
      </p>
    {% endif %}
    <input type="hidden" name="next" value="{{ next }}" />
    {{ form.content_type }}{{ form.object_pk }}{{ form.timestamp }}{{ form.security_hash }}
    <p style="display: none">{{ form.honeypot.label_tag }}{{ form.honeypot }}</p>
	<table class="module" id="commentform">
	  <caption>{% trans "Update comment" %}</caption>
	  <tr {% if form.name.errors %}class="error"{% endif %}>
	  	<th scope="row"><label for="id_name">{% trans "Your name" %}</label></th>
	  	<td>{{ form.name.errors }}{% if user.is_authenticated %}{{ user.first_name }} {{ user.last_name }}<input type="hidden" name="name" value="{{ user.first_name }}{{ user.last_name }}" />{% else %}{{ form.name }}{% endif %}</td>
	  </tr>
	  <tr {% if form.email.errors %}class="error"{% endif %}>
	  	<th scope="row"><label for="id_email">{% trans "Your email" %}</label></th>
	  	<td>{{ form.email.errors }}{% if user.is_authenticated %}{{ user.email }}<input type="hidden" name="email" value="{{ user.email }}" />{% else %}{{ form.email }}{% endif %}</td>
	  </tr>
	  <tr {% if form.url.errors %}class="error"{% endif %}>
	  	<th scope="row"><label for="id_url">{% trans "Your website (optional)" %}</label></th>
	  	<td>{{ form.url.errors }}{{ form.url }}</td>
	  </tr>
	  <tr {% if form.comment.errors %}class="error"{% endif %}>
	    <th scope="row"><label for="id_comment">{% trans "Your thoughts" %}</label></th>
	    <td>{{ form.comment.errors }}{{ form.comment }}</td>
	  </tr>	  	
	</table>
    <p class="submit">
    <input type="submit" name="submit" class="submit-post" value="{% trans "Post" %}" />
    <input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
    </p>
  </form>
{% endblock %}
